<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Utilities</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Utilities' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../extensions.html">Kits</a></li><li><a href="index.html">BasicInformKit</a></li><li><b>Utilities</b></li></ul></div>
<p class="purpose">Utilities  Miscellaneous utility routines for some fundamental I6 needs.</p>

<ul class="toc"><li><a href="utlts.html#SP1">&#167;1. Miscellany</a></li><li><a href="utlts.html#SP2">&#167;2. Final Code Dependencies</a></li><li><a href="utlts.html#SP3">&#167;3. Firebreak</a></li><li><a href="utlts.html#SP4">&#167;4. Print Decimal Number</a></li><li><a href="utlts.html#SP5">&#167;5. Print Text</a></li><li><a href="utlts.html#SP6">&#167;6. Print Or Run</a></li><li><a href="utlts.html#SP7">&#167;7. Saying Phrases</a></li><li><a href="utlts.html#SP8">&#167;8. Redrawing the Status Window</a></li><li><a href="utlts.html#SP9">&#167;9. GenerateRandomNumber</a></li><li><a href="utlts.html#SP10">&#167;10. PrintSpaces</a></li><li><a href="utlts.html#SP11">&#167;11. SwapWorkflags</a></li><li><a href="utlts.html#SP12">&#167;12. TestUseOption</a></li><li><a href="utlts.html#SP13">&#167;13. ZRegion</a></li><li><a href="utlts.html#SP14">&#167;14. Arrcpy</a></li><li><a href="utlts.html#SP15">&#167;15. Verbs as Values</a></li><li><a href="utlts.html#SP16">&#167;16. Regarding</a></li><li><a href="utlts.html#SP17">&#167;17. Say One Of</a></li><li><a href="utlts.html#SP18">&#167;18. Rounding</a></li><li><a href="utlts.html#SP19">&#167;19. Doing nothing</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Miscellany.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">#</span><span class="identifier-syntax">Iftrue</span><span class="plain-syntax"> </span><span class="identifier-syntax">WORDSIZE</span><span class="plain-syntax"> == </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">BLOCKV_STACK_SIZE</span><span class="plain-syntax"> = </span><span class="constant-syntax">224</span><span class="plain-syntax">;</span>
<span class="plain-syntax">#</span><span class="identifier-syntax">ifnot</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">BLOCKV_STACK_SIZE</span><span class="plain-syntax"> = </span><span class="identifier-syntax">BasicInformKit</span><span class="plain-syntax">`</span><span class="identifier-syntax">STACK_FRAME_CAPACITY_CFGV</span><span class="plain-syntax"> / </span><span class="constant-syntax">4</span><span class="plain-syntax">;</span>
<span class="plain-syntax">#</span><span class="identifier-syntax">endif</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">Array</span><span class="plain-syntax"> </span><span class="identifier-syntax">blockv_stack</span><span class="plain-syntax"> --&gt; </span><span class="identifier-syntax">BLOCKV_STACK_SIZE</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7SFRAME</span><span class="plain-syntax">;</span>

<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">TEXT_TY_RE_Err</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">prior_named_noun</span><span class="plain-syntax">; </span><span class="comment-syntax">for adaptive text generation</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">prior_named_list</span><span class="plain-syntax">; </span><span class="comment-syntax">ditto: length of list of items</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">prior_named_list_gender</span><span class="plain-syntax">; </span><span class="comment-syntax">ditto: common gender of list of items, or -1</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">story_tense</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax">ditto: present tense</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">story_viewpoint</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">; </span><span class="comment-syntax">ditto: second person singular</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__p</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__pc</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__pc_save</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__n</span><span class="plain-syntax">; </span><span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__comp</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">los_rv</span><span class="plain-syntax"> = </span><span class="reserved-syntax">false</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">parameter_object</span><span class="plain-syntax">; </span><span class="comment-syntax">= I7 "parameter-object" = I7 "container in question"</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">parameter_value</span><span class="plain-syntax">; </span><span class="comment-syntax">not typesafe in I7</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">property_to_be_totalled</span><span class="plain-syntax">; </span><span class="comment-syntax">used to implement "total P of..."</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">property_loop_sign</span><span class="plain-syntax">; </span>\(+1\)<span class="comment-syntax"> for increasing order, </span>\(-1\)<span class="comment-syntax"> for decreasing</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">suppress_scope_loops</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">temporary_value</span><span class="plain-syntax">; </span><span class="comment-syntax">can be used anywhere side-effects can't occur</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">statuswin_current</span><span class="plain-syntax">; </span><span class="comment-syntax">if writing to top window</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">suppress_text_substitution</span><span class="plain-syntax"> = </span><span class="reserved-syntax">false</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">deadflag</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>

<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">statuswin_cursize</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">statuswin_size</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>

<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">debug_dialogue</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">debug_rules</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">debug_rule_nesting</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">reason_the_action_failed</span><span class="plain-syntax">; </span><span class="comment-syntax">= I7 "reason the action failed"</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">indef_mode</span><span class="plain-syntax">;                  </span><span class="comment-syntax">"Indefinite" mode - ie, "take a brick"</span>
<span class="plain-syntax">                                    </span><span class="comment-syntax">is in this mode</span>

<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">standard_interpreter</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>

<span class="identifier-syntax">Default</span><span class="plain-syntax"> </span><span class="identifier-syntax">LanguageCases</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Final Code Dependencies.</b>This function definition is a little misleading. The idea is that the
final code-generator can inject code of its own into the body here: for example,
the final code-generation for Glulx injects code into <span class="extract"><span class="extract-syntax">PLATFORM_SPECIFIC_STARTUP_R</span></span>
to use accelerated VM support for certain veneer functions.
</p>

<p class="commentary">The other three are also misleading, in that final code-generation can add more
helpful code here: the fallbacks here are basic.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PLATFORM_SPECIFIC_STARTUP_R</span><span class="plain-syntax"> </span><span class="identifier-syntax">addr</span><span class="plain-syntax"> </span><span class="identifier-syntax">res</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DebugAction</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">anames</span><span class="plain-syntax"> </span><span class="identifier-syntax">str</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">a</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">4096</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"&lt;fake action "</span><span class="plain-syntax">, </span><span class="identifier-syntax">a</span><span class="plain-syntax">-4096, </span><span class="string-syntax">"&gt;"</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"&lt;action "</span><span class="plain-syntax">, </span><span class="identifier-syntax">a</span><span class="plain-syntax">, </span><span class="string-syntax">"&gt;"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DebugAttribute</span><span class="plain-syntax"> </span><span class="identifier-syntax">a</span><span class="plain-syntax"> </span><span class="identifier-syntax">anames</span><span class="plain-syntax"> </span><span class="identifier-syntax">str</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"&lt;attribute "</span><span class="plain-syntax">, </span><span class="identifier-syntax">a</span><span class="plain-syntax">, </span><span class="string-syntax">"&gt;"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DebugProperty</span><span class="plain-syntax"> </span><span class="identifier-syntax">p</span><span class="plain-syntax"> </span><span class="identifier-syntax">pnames</span><span class="plain-syntax"> </span><span class="identifier-syntax">str</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"&lt;property "</span><span class="plain-syntax">, </span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="string-syntax">"&gt;"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Firebreak.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">Array</span><span class="plain-syntax"> </span><span class="identifier-syntax">Protect_I7_Arrays</span><span class="plain-syntax"> --&gt; </span><span class="constant-syntax">16339</span><span class="plain-syntax"> </span><span class="constant-syntax">12345</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Print Decimal Number.</b><span class="extract"><span class="extract-syntax">DecimalNumber</span></span> is a trivial function which just prints a number, in decimal
digits. It is left over from the I6 library's support routines for Glulx,
where it was intended as a stub to pass to the Glulx <span class="extract"><span class="extract-syntax">Glulx_PrintAnything</span></span> routine
(which I7 does not use). In I7, however, it's also used as the default
printing routine for new kinds of value.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DecimalNumber</span><span class="plain-syntax"> </span><span class="identifier-syntax">num</span><span class="plain-syntax">; </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="identifier-syntax">num</span><span class="plain-syntax">; ];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Print Text.</b>The routine for printing an I7 "text" value, which might be text with or
without substitutions.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PrintI6Text</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">String</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">Routine</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax">)();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">x</span><span class="plain-syntax"> == </span><span class="identifier-syntax">EMPTY_TEXT_PACKED</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_String</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">; </span><span class="identifier-syntax">TEXT_TY_Say</span><span class="plain-syntax">(</span><span class="identifier-syntax">x</span><span class="plain-syntax">); ]; </span><span class="comment-syntax">An alternative name now used only by extensions</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Print Or Run.</b>This utility remains from the old I6 library: it essentially treats a
property as textual and prints it where possible. Where the <span class="extract"><span class="extract-syntax">no_break</span></span>
flag is set, we expect the text to form only a small part of a paragraph,
and it's inappropriate to break here: for instance, for printing the
"printed name" of an object. Where the flag is clear, however, the text
is expected to form its own paragraph.
</p>

<p class="commentary">Where <span class="extract"><span class="extract-syntax">PrintOrRun</span></span> is used in breaking mode, which is only for a very few
properties in I7 (indeed at present only <span class="extract"><span class="extract-syntax">initial</span></span> and <span class="extract"><span class="extract-syntax">description</span></span>),
the routine called is given the chance to decide whether to print or not.
It should return <span class="extract"><span class="extract-syntax">true</span></span> or <span class="extract"><span class="extract-syntax">false</span></span> according to whether it did so; this
allows us to divide the paragraph or not accordingly.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PrintOrRun</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">prop</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_break</span><span class="plain-syntax">  </span><span class="identifier-syntax">pv</span><span class="plain-syntax"> </span><span class="identifier-syntax">st</span><span class="plain-syntax"> </span><span class="identifier-syntax">routine_return_value</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">self</span><span class="plain-syntax">; </span><span class="identifier-syntax">self</span><span class="plain-syntax"> = </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prop</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">name</span><span class="plain-syntax">) </span><span class="identifier-syntax">prop</span><span class="plain-syntax">; </span><span class="identifier-syntax">routine_return_value</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">routine_return_value</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TEXT_TY_Say</span><span class="plain-syntax">(</span><span class="identifier-syntax">obj</span><span class="plain-syntax">.</span><span class="identifier-syntax">prop</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">self</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">routine_return_value</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">say__p</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">no_break</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">new_line</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DivideParagraphPoint</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">routine_return_value</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DA_Number</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">; </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">; ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">DA_TruthState</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax">==0) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"false"</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"true"</span><span class="plain-syntax">; ];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Saying Phrases.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">SayPhraseName</span><span class="plain-syntax"> </span><span class="identifier-syntax">closure</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">closure</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"nothing"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">closure</span><span class="plain-syntax">--&gt;2;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Redrawing the Status Window.</b>These functions handle the default behaviour of redrawing the status window.
</p>

<p class="commentary">Status line printing happens on the upper screen window, and outside of the
paragraph control system.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DrawStatusLine</span><span class="plain-syntax"> </span><span class="identifier-syntax">width</span><span class="plain-syntax"> </span><span class="identifier-syntax">posb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">TARGET_GLULX</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">gg_statuswin</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    #</span><span class="identifier-syntax">endif</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__p</span><span class="plain-syntax">; @</span><span class="identifier-syntax">push</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__pc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">VM_MoveCursorInStatusLine</span><span class="plain-syntax">(1, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CarryOutActivity</span><span class="plain-syntax">(</span><span class="identifier-syntax">CONSTRUCTING_STATUS_LINE_ACT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">VM_MainWindow</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ClearParagraphing</span><span class="plain-syntax">(18);</span>
<span class="plain-syntax">    @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__pc</span><span class="plain-syntax">; @</span><span class="identifier-syntax">pull</span><span class="plain-syntax"> </span><span class="identifier-syntax">say__p</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">;</span>

<span class="comment-syntax">A little helper text for getting the length of a value</span>
<span class="reserved-syntax">Array</span><span class="plain-syntax"> </span><span class="identifier-syntax">status_window_table_temp_text</span><span class="plain-syntax"> --&gt; [ </span><span class="identifier-syntax">CONSTANT_PACKED_TEXT_STORAGE</span><span class="plain-syntax">; </span><span class="identifier-syntax">Print_Status_Window_Entry</span><span class="plain-syntax">; ];</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">status_window_table_kov</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">Global</span><span class="plain-syntax"> </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax">;</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">Print_Status_Window_Entry</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table_kov</span><span class="plain-syntax">, </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">REDRAW_STATUS_WINDOW_R</span><span class="plain-syntax">  </span><span class="identifier-syntax">chars</span><span class="plain-syntax"> </span><span class="identifier-syntax">col_kov_left</span><span class="plain-syntax"> </span><span class="identifier-syntax">col_kov_middle</span><span class="plain-syntax"> </span><span class="identifier-syntax">col_kov_right</span><span class="plain-syntax"> </span><span class="identifier-syntax">col_num_left</span><span class="plain-syntax"> </span><span class="identifier-syntax">col_num_middle</span><span class="plain-syntax"> </span><span class="identifier-syntax">col_num_right</span><span class="plain-syntax"> </span><span class="identifier-syntax">rows</span><span class="plain-syntax"> </span><span class="identifier-syntax">row</span><span class="plain-syntax"> </span><span class="identifier-syntax">width</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rows</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TableRows</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">VM_StatusLineHeight</span><span class="plain-syntax">(</span><span class="identifier-syntax">rows</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">VM_ClearScreen</span><span class="plain-syntax">(1);</span>
<span class="plain-syntax">    </span><span class="comment-syntax">Cache the column details in case we have a lot of rows</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;0) {</span>
<span class="plain-syntax">        </span><span class="constant-syntax">1</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_num_middle</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_kov_middle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TC_KOV</span><span class="plain-syntax">(((</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;1)--&gt;1) &amp; </span><span class="identifier-syntax">TB_COLUMN_NUMBER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="constant-syntax">2</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_num_left</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_kov_left</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TC_KOV</span><span class="plain-syntax">(((</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;1)--&gt;1) &amp; </span><span class="identifier-syntax">TB_COLUMN_NUMBER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_num_right</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_kov_right</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TC_KOV</span><span class="plain-syntax">(((</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;2)--&gt;1) &amp; </span><span class="identifier-syntax">TB_COLUMN_NUMBER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="constant-syntax">3</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_num_left</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_kov_left</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TC_KOV</span><span class="plain-syntax">(((</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;1)--&gt;1) &amp; </span><span class="identifier-syntax">TB_COLUMN_NUMBER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_num_middle</span><span class="plain-syntax"> = </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_kov_middle</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TC_KOV</span><span class="plain-syntax">(((</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;2)--&gt;1) &amp; </span><span class="identifier-syntax">TB_COLUMN_NUMBER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_num_right</span><span class="plain-syntax"> = </span><span class="constant-syntax">3</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">col_kov_right</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TC_KOV</span><span class="plain-syntax">(((</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;3)--&gt;1) &amp; </span><span class="identifier-syntax">TB_COLUMN_NUMBER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">width</span><span class="plain-syntax"> = </span><span class="identifier-syntax">VM_ScreenWidth</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">row</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">row</span><span class="plain-syntax"> &lt;= </span><span class="identifier-syntax">rows</span><span class="plain-syntax">: </span><span class="identifier-syntax">row</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TableRowIsBlank</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">row</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">col_num_left</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">col_num_left</span><span class="plain-syntax">)--&gt;(</span><span class="identifier-syntax">row</span><span class="plain-syntax"> + </span><span class="identifier-syntax">COL_HSIZE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">TABLE_NOVALUE</span><span class="plain-syntax">) || ~~(</span><span class="identifier-syntax">CheckTableEntryIsBlank</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">col_num_left</span><span class="plain-syntax">, </span><span class="identifier-syntax">row</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">VM_MoveCursorInStatusLine</span><span class="plain-syntax">(</span><span class="identifier-syntax">row</span><span class="plain-syntax">, </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">col_kov_left</span><span class="plain-syntax">, </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">col_num_right</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">col_num_right</span><span class="plain-syntax">)--&gt;(</span><span class="identifier-syntax">row</span><span class="plain-syntax"> + </span><span class="identifier-syntax">COL_HSIZE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">TABLE_NOVALUE</span><span class="plain-syntax">) || ~~(</span><span class="identifier-syntax">CheckTableEntryIsBlank</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">col_num_right</span><span class="plain-syntax">, </span><span class="identifier-syntax">row</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">status_window_table_kov</span><span class="plain-syntax"> = </span><span class="identifier-syntax">col_kov_right</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">chars</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table_temp_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">VM_MoveCursorInStatusLine</span><span class="plain-syntax">(</span><span class="identifier-syntax">row</span><span class="plain-syntax">, </span><span class="identifier-syntax">width</span><span class="plain-syntax"> - </span><span class="identifier-syntax">chars</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">col_kov_right</span><span class="plain-syntax">, </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">col_num_middle</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">col_num_middle</span><span class="plain-syntax">)--&gt;(</span><span class="identifier-syntax">row</span><span class="plain-syntax"> + </span><span class="identifier-syntax">COL_HSIZE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">TABLE_NOVALUE</span><span class="plain-syntax">) || ~~(</span><span class="identifier-syntax">CheckTableEntryIsBlank</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">col_num_middle</span><span class="plain-syntax">, </span><span class="identifier-syntax">row</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">status_window_table_kov</span><span class="plain-syntax"> = </span><span class="identifier-syntax">col_kov_middle</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">chars</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TEXT_TY_BlobAccess</span><span class="plain-syntax">(</span><span class="identifier-syntax">status_window_table_temp_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">CHR_BLOB</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">VM_MoveCursorInStatusLine</span><span class="plain-syntax">(</span><span class="identifier-syntax">row</span><span class="plain-syntax">, ((</span><span class="identifier-syntax">width</span><span class="plain-syntax"> - </span><span class="identifier-syntax">chars</span><span class="plain-syntax">) / </span><span class="constant-syntax">2</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">col_kov_middle</span><span class="plain-syntax">, </span><span class="identifier-syntax">status_window_table_value</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. GenerateRandomNumber.</b>The following uses the virtual machine's RNG (via the I6 built-in function
<span class="extract"><span class="extract-syntax">random</span></span>) to produce a uniformly random integer in the range \(n\) to \(m\)
inclusive, where \(n\) and \(m\) are allowed to be either way around; so that
a random number between 17 and 4 is the same thing as a random number
between 4 and 17, and there is therefore no pair of \(n\) and \(m\) corresponding
to an empty range of values.
</p>

<p class="commentary">The following trick, devised by Zed Lopez in 2023, is designed to work even
when the range width (here called \(s\)) is larger than the maximum signed
integer size, so that the signed comparison \(s &gt; 0\) fails. In that case, it
appears alarmingly to go into an infinite loop, but the loop terminates with
a probability of at least 0.5 on each iteration. Even in the worst case of the
range, the expected number of iterations is only 2, and the probability of taking
more than 50 iterations is less than 0.0000000000000001, which is obviously
negligible. But we check the iteration count anyway in case a rigged random
number generator is being used, e.g. for story testing purposes, which happens
to be biased in a really unlucky way for us.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">GenerateRandomNumber</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax"> </span><span class="identifier-syntax">s</span><span class="plain-syntax"> </span><span class="identifier-syntax">it</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax">==</span><span class="identifier-syntax">m</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax">&gt;</span><span class="identifier-syntax">m</span><span class="plain-syntax">) { </span><span class="identifier-syntax">s</span><span class="plain-syntax"> = </span><span class="identifier-syntax">n</span><span class="plain-syntax">; </span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="identifier-syntax">m</span><span class="plain-syntax">; </span><span class="identifier-syntax">m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">s</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">n</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">s</span><span class="plain-syntax"> = </span><span class="identifier-syntax">m</span><span class="plain-syntax"> - </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">s</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">random</span><span class="plain-syntax">(</span><span class="identifier-syntax">s</span><span class="plain-syntax">) + </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">n</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">do</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">s</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FullyRandomWord</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">s</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">n</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">s</span><span class="plain-syntax"> &lt;= </span><span class="identifier-syntax">m</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">s</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">it</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">until</span><span class="plain-syntax"> (</span><span class="identifier-syntax">it</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">50</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">R_DecimalNumber</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GenerateRandomNumber</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">R_PrintTimeOfDay</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GenerateRandomNumber</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. PrintSpaces.</b>Which prints a row of \(n\) spaces, for \(n\geq 0\).
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PrintSpaces</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="identifier-syntax">n</span><span class="plain-syntax"> - </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. SwapWorkflags.</b>Recall that we have two general-purpose temporary attributes for each object:
<span class="extract"><span class="extract-syntax">workflag</span></span> and <span class="extract"><span class="extract-syntax">workflag2</span></span>. The following swaps their values over for every
object at once.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">SwapWorkflags</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">lst</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">objectloop</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">ofclass</span><span class="plain-syntax"> </span><span class="identifier-syntax">Object</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">lst</span><span class="plain-syntax"> = </span><span class="reserved-syntax">false</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">workflag2</span><span class="plain-syntax">) </span><span class="identifier-syntax">lst</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">workflag2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="reserved-syntax">has</span><span class="plain-syntax"> </span><span class="identifier-syntax">workflag</span><span class="plain-syntax">) </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">workflag2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">workflag</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">lst</span><span class="plain-syntax">) </span><span class="reserved-syntax">give</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax"> </span><span class="identifier-syntax">workflag</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. TestUseOption.</b>This routine, compiled by Inform, returns <span class="extract"><span class="extract-syntax">true</span></span> if the supplied argument is the
number of a use option in force for the current run of Inform, and <span class="extract"><span class="extract-syntax">false</span></span>
otherwise.
</p>

<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. ZRegion.</b>I7 contains many relics from I6, but here's a relic from I5: a routine which
used to determine the metaclass of a value, before that concept was given a
name. In I6 code, it can be implemented simply using <span class="extract"><span class="extract-syntax">metaclass</span></span>, as the
following shows. (The name is from "region of the Z-machine".)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ZRegion</span><span class="plain-syntax"> </span><span class="identifier-syntax">addr</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="reserved-syntax">metaclass</span><span class="plain-syntax">(</span><span class="identifier-syntax">addr</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Object</span><span class="plain-syntax">, </span><span class="identifier-syntax">Class</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Routine</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">String</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Arrcpy.</b>This is not quite so efficient as Memcpy, but not terrible.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">Arrcpy</span><span class="plain-syntax"> </span><span class="identifier-syntax">to_array</span><span class="plain-syntax"> </span><span class="identifier-syntax">to_entry_size</span><span class="plain-syntax"> </span><span class="identifier-syntax">from_array</span><span class="plain-syntax"> </span><span class="identifier-syntax">from_entry_size</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_entries</span><span class="plain-syntax">  </span><span class="identifier-syntax">n</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">to_entry_size</span><span class="plain-syntax"> == </span><span class="identifier-syntax">from_entry_size</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Memcpy</span><span class="plain-syntax">(</span><span class="identifier-syntax">to_array</span><span class="plain-syntax">, </span><span class="identifier-syntax">from_array</span><span class="plain-syntax">, </span><span class="identifier-syntax">to_entry_size</span><span class="plain-syntax">*</span><span class="identifier-syntax">no_entries</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">to_entry_size</span><span class="plain-syntax"> == </span><span class="constant-syntax">2</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">from_entry_size</span><span class="plain-syntax"> == </span><span class="constant-syntax">4</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">n</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">no_entries</span><span class="plain-syntax">: </span><span class="identifier-syntax">n</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">val</span><span class="plain-syntax"> = </span><span class="identifier-syntax">from_array</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">to_array</span><span class="plain-syntax">-&gt;0 = (</span><span class="identifier-syntax">val</span><span class="plain-syntax">/256)%256; </span><span class="identifier-syntax">to_array</span><span class="plain-syntax">-&gt;1 = </span><span class="identifier-syntax">val</span><span class="plain-syntax">%256;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">to_array</span><span class="plain-syntax"> = </span><span class="identifier-syntax">to_array</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Arrcpy doesn't support this ***"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. Verbs as Values.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PrintVerbAsValue</span><span class="plain-syntax"> </span><span class="identifier-syntax">vb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">vb</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"(no verb)"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> { </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"verb "</span><span class="plain-syntax">; </span><span class="identifier-syntax">vb</span><span class="plain-syntax">(1); }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">VerbIsMeaningful</span><span class="plain-syntax"> </span><span class="identifier-syntax">vb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">vb</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">vb</span><span class="plain-syntax">(</span><span class="identifier-syntax">CV_MEANING</span><span class="plain-syntax">), </span><span class="identifier-syntax">MEANINGLESS_RR</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">VerbIsModal</span><span class="plain-syntax"> </span><span class="identifier-syntax">vb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">vb</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">vb</span><span class="plain-syntax">(</span><span class="identifier-syntax">CV_MODAL</span><span class="plain-syntax">))) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. Regarding.</b>These are used with adaptive text.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RegardingSingleObject</span><span class="plain-syntax"> </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">prior_named_list</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">prior_named_list_gender</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">prior_named_noun</span><span class="plain-syntax"> = </span><span class="identifier-syntax">obj</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RegardingNumber</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">prior_named_list</span><span class="plain-syntax"> = </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">prior_named_list_gender</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">prior_named_noun</span><span class="plain-syntax"> = </span><span class="reserved-syntax">nothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. Say One Of.</b>These routines are described in the Extensions chapter of the Inform
documentation.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_PAR</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="reserved-syntax">random</span><span class="plain-syntax">(</span><span class="identifier-syntax">count</span><span class="plain-syntax">); ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_RAN</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">; </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax"> == </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">) </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="reserved-syntax">random</span><span class="plain-syntax">(</span><span class="identifier-syntax">count</span><span class="plain-syntax">); </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax">; ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_STI</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">oldval</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_PAR</span><span class="plain-syntax">(</span><span class="identifier-syntax">oldval</span><span class="plain-syntax">, </span><span class="identifier-syntax">count</span><span class="plain-syntax">); ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_CYC</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">++; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">count</span><span class="plain-syntax">) </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">; ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_STOP</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">++; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">count</span><span class="plain-syntax">) </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> = </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">; ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_TAP</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> </span><span class="identifier-syntax">tn</span><span class="plain-syntax"> </span><span class="identifier-syntax">rn</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="identifier-syntax">tn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">count</span><span class="plain-syntax">*(</span><span class="identifier-syntax">count</span><span class="plain-syntax">+1)/2;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rn</span><span class="plain-syntax"> = </span><span class="reserved-syntax">random</span><span class="plain-syntax">(</span><span class="identifier-syntax">tn</span><span class="plain-syntax">); </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax">=1:</span><span class="identifier-syntax">c</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">count</span><span class="plain-syntax">:</span><span class="identifier-syntax">c</span><span class="plain-syntax">++) { </span><span class="identifier-syntax">rn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">rn</span><span class="plain-syntax"> - </span><span class="identifier-syntax">c</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rn</span><span class="plain-syntax">&lt;=0) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count</span><span class="plain-syntax">-</span><span class="identifier-syntax">c</span><span class="plain-syntax">+1); } ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_TRAN</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">oldval</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">+1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax"> + </span><span class="identifier-syntax">I7_SOO_RAN</span><span class="plain-syntax">(</span><span class="identifier-syntax">oldval</span><span class="plain-syntax">%(</span><span class="identifier-syntax">count</span><span class="plain-syntax">+1), </span><span class="identifier-syntax">count</span><span class="plain-syntax">); ];</span>
<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_TPAR</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">oldval</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">count</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">+1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax"> + </span><span class="identifier-syntax">I7_SOO_PAR</span><span class="plain-syntax">(</span><span class="identifier-syntax">oldval</span><span class="plain-syntax">%(</span><span class="identifier-syntax">count</span><span class="plain-syntax">+1), </span><span class="identifier-syntax">count</span><span class="plain-syntax">); ];</span>

<span class="reserved-syntax">Array</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_SHUF</span><span class="plain-syntax">-&gt;32;</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">I7_SOO_SHU</span><span class="plain-syntax"> </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> </span><span class="identifier-syntax">count</span><span class="plain-syntax"> </span><span class="identifier-syntax">sd</span><span class="plain-syntax"> </span><span class="identifier-syntax">ct</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax"> </span><span class="identifier-syntax">s</span><span class="plain-syntax"> </span><span class="identifier-syntax">ssd</span><span class="plain-syntax"> </span><span class="identifier-syntax">scope</span><span class="plain-syntax"> </span><span class="identifier-syntax">cc</span><span class="plain-syntax"> </span><span class="identifier-syntax">base</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">base</span><span class="plain-syntax"> = </span><span class="identifier-syntax">count</span><span class="plain-syntax">+1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">%</span><span class="identifier-syntax">base</span><span class="plain-syntax">; </span><span class="identifier-syntax">oldval</span><span class="plain-syntax"> = </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">/</span><span class="identifier-syntax">base</span><span class="plain-syntax">; </span><span class="identifier-syntax">ct</span><span class="plain-syntax"> = </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">%</span><span class="identifier-syntax">base</span><span class="plain-syntax">; </span><span class="identifier-syntax">sd</span><span class="plain-syntax"> = </span><span class="identifier-syntax">oldval</span><span class="plain-syntax">/</span><span class="identifier-syntax">base</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">32</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">I7_SOO_PAR</span><span class="plain-syntax">(</span><span class="identifier-syntax">oldval</span><span class="plain-syntax">, </span><span class="identifier-syntax">count</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">count</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">count</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">rint "^In v=", v, " ct=", ct, " sd=", sd, "^";</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">cc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">base</span><span class="plain-syntax">*</span><span class="identifier-syntax">base</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">scope</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">MAX_POSITIVE_NUMBER</span><span class="plain-syntax">-1)/</span><span class="identifier-syntax">cc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="comment-syntax">rint "Scope = ", scope, "^";</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sd</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) { </span><span class="identifier-syntax">sd</span><span class="plain-syntax"> = </span><span class="reserved-syntax">random</span><span class="plain-syntax">(</span><span class="identifier-syntax">scope</span><span class="plain-syntax">); </span><span class="identifier-syntax">ct</span><span class="plain-syntax">=0; }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0:</span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">count</span><span class="plain-syntax">:</span><span class="identifier-syntax">i</span><span class="plain-syntax">++) </span><span class="identifier-syntax">I7_SOO_SHUF</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ssd</span><span class="plain-syntax"> = </span><span class="identifier-syntax">sd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0:</span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">count</span><span class="plain-syntax">-1:</span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">j</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">sd</span><span class="plain-syntax">)%(</span><span class="identifier-syntax">count</span><span class="plain-syntax">-</span><span class="identifier-syntax">i</span><span class="plain-syntax">)+</span><span class="identifier-syntax">i</span><span class="plain-syntax">; </span><span class="identifier-syntax">sd</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">sd</span><span class="plain-syntax">*31973)+17; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sd</span><span class="plain-syntax">&lt;0) </span><span class="identifier-syntax">sd</span><span class="plain-syntax">=-</span><span class="identifier-syntax">sd</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">s</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I7_SOO_SHUF</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">j</span><span class="plain-syntax">; </span><span class="identifier-syntax">I7_SOO_SHUF</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">j</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I7_SOO_SHUF</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">; </span><span class="identifier-syntax">I7_SOO_SHUF</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">s</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="comment-syntax">or (i=0:i&lt;count:i++) print I7_SOO_SHUF-&gt;i, " "; print "^";</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">I7_SOO_SHUF</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">ct</span><span class="plain-syntax">)+1;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ct</span><span class="plain-syntax">++; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ct</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">count</span><span class="plain-syntax">) { </span><span class="identifier-syntax">ct</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="identifier-syntax">ssd</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="comment-syntax">rint "Out v=", v, " ct=", ct, " ssd=", sd, "^";</span>
<span class="plain-syntax">    </span><span class="comment-syntax">rint "Return ", v + ct*base + ssd*base*base, "^";</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax"> + </span><span class="identifier-syntax">ct</span><span class="plain-syntax">*</span><span class="identifier-syntax">base</span><span class="plain-syntax"> + </span><span class="identifier-syntax">ssd</span><span class="plain-syntax">*</span><span class="identifier-syntax">base</span><span class="plain-syntax">*</span><span class="identifier-syntax">base</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. Rounding.</b>The following rounds a numerical value <span class="extract"><span class="extract-syntax">t1</span></span> to the nearest unit of <span class="extract"><span class="extract-syntax">t2</span></span>;
for instance, if <span class="extract"><span class="extract-syntax">t2</span></span> is 5 then it rounds to the nearest 5. The name is an
anachronism, as it's used for all kinds of value.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RoundOffValue</span><span class="plain-syntax"> </span><span class="identifier-syntax">t1</span><span class="plain-syntax"> </span><span class="identifier-syntax">t2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t1</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">t1</span><span class="plain-syntax">+</span><span class="identifier-syntax">t2</span><span class="plain-syntax">/2)/</span><span class="identifier-syntax">t2</span><span class="plain-syntax">)*</span><span class="identifier-syntax">t2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -((-</span><span class="identifier-syntax">t1</span><span class="plain-syntax">+</span><span class="identifier-syntax">t2</span><span class="plain-syntax">/2)/</span><span class="identifier-syntax">t2</span><span class="plain-syntax">)*</span><span class="identifier-syntax">t2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Doing nothing.</b>Surprisingly, this function has a use.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DoNothing</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="strtp.html">&#10094;</a></li><li class="progresssection"><a href="dfntn.html">dfntn</a></li><li class="progresssection"><a href="strtp.html">strtp</a></li><li class="progresscurrent">utlts</li><li class="progresssection"><a href="prgrp.html">prgrp</a></li><li class="progresssection"><a href="mthmt.html">mthmt</a></li><li class="progresssection"><a href="srt.html">srt</a></li><li class="progresssection"><a href="tbls.html">tbls</a></li><li class="progresssection"><a href="mstck.html">mstck</a></li><li class="progresssection"><a href="rlbks.html">rlbks</a></li><li class="progresssection"><a href="actvt.html">actvt</a></li><li class="progresssection"><a href="prntn.html">prntn</a></li><li class="progresssection"><a href="flx.html">flx</a></li><li class="progresssection"><a href="blckv.html">blckv</a></li><li class="progresssection"><a href="knds.html">knds</a></li><li class="progresssection"><a href="txt.html">txt</a></li><li class="progresssection"><a href="chr.html">chr</a></li><li class="progresssection"><a href="rgxp.html">rgxp</a></li><li class="progresssection"><a href="lsts.html">lsts</a></li><li class="progresssection"><a href="cmbnt.html">cmbnt</a></li><li class="progresssection"><a href="rltnk.html">rltnk</a></li><li class="progresssection"><a href="rltns.html">rltns</a></li><li class="progresssection"><a href="prprt.html">prprt</a></li><li class="progresssection"><a href="rtp.html">rtp</a></li><li class="progressnext"><a href="prgrp.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

